#include<stdio.h>
int my_best(int arr1[20][20], int arr2[20][20], int x, int y)
{
	int i = 0;
	int j = 0;
	int count = 0;
	for (i = 0; i < x; i++)
	{
		for (j = 0; j < y; j++)
		{
			if (arr1[i][j] == arr2[i][j])
				count++;
		}
	}
	if (count == x * y)
		return 1;
	else
	    return 0;
}
int main()
{
	int x = 0;
	int y = 0;
	scanf_s("%d%d",&x,&y);
	int arr1[20][20] = { 0 };
	int arr2[20][20] = { 0 };
	int i = 0;
	int j = 0;
	for (i = 0; i < x; i++)
	{
		for (j = 0; j < y; j++)
		{
			scanf_s("%d",&arr1[i][j]);
		}
	}
	for (i = 0; i < x; i++)
	{
		for (j = 0; j < y; j++)
		{
			scanf_s("%d", &arr2[i][j]);
		}
	}
	int ret=my_best(arr1, arr2, x, y);
	if (ret == 1)
		printf("yes\n");
	else
		printf("no\n");
	
	return 0;
}